package com.raymond.algorithm.utils;

import java.util.concurrent.ScheduledThreadPoolExecutor;

/**
 * 线程池管理
 *
 * @author :  raymond
 * @version :  V1.0
 * @date :  2021-04-23 10:48
 */
public class ThreadPool {
    /**
     * 获取定时线程池
     * @param threadName 线程名称
     * @return 定时线程池
     */
    public static ScheduledThreadPoolExecutor javaScheduledThreadExecutor(String threadName) {
        return new ScheduledThreadPoolExecutor(1, r -> {
            Thread thread = new Thread(r);
            thread.setName(threadName);
            thread.setDaemon(true);
            return thread;
        });
    }
}
